home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / DVDZone2 (FR).ifs < prev    next >
Text File  |  2005-03-13  |  8KB  |  262 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Antoine Potten, Candyghost
  8. Title=DVDZone2 (Franτais)
  9. Description=Version franτaise de DVDZone2
  10. Site=http://www.dvdzone2.com
  11. Language=FR
  12. Version=
  13. Requires=3.5.0
  14. Comments= Rewritten by Antoine Potten Adapted by Candyghost Fixed Lenght + added subtitles
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program DVDZone2_FR;
  23. var
  24.   MovieName: string;
  25.  
  26. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  27. var
  28.   i: Integer;
  29. begin
  30.   result := -1;
  31.   if StartAt < 0 then
  32.     StartAt := 0;
  33.   for i := StartAt to List.Count-1 do
  34.     if Pos(Pattern, List.GetString(i)) <> 0 then
  35.     begin
  36.       result := i;
  37.       Break;
  38.     end;
  39. end;
  40.  
  41. procedure AnalyzePage(Address: string);
  42. var
  43.   Line, MovieItem, MovieTitle, MovieAddress: string;
  44.   TitlePos, BeginPos, EndPos: Integer;
  45.   List: TStringList;
  46. begin
  47.   Line := GetPage(Address);
  48.   PickTreeClear;
  49.   if Pos('</b> : 0 item(s) found<br>', Line) = 0 then
  50.   begin
  51.     PickTreeAdd('Search results from DVDZone2', '');
  52.     BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  53.     EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  54.     Line := Copy(Line, BeginPos, EndPos - BeginPos);
  55.     List := TStringList.Create;
  56.     repeat
  57.       TitlePos := Pos('<a href="http://www.dvdzone2.com/dvd/detail.asp', Line);
  58.       if TitlePos > 0 then
  59.       begin
  60.         Delete(Line, 1, TitlePos);
  61.         MovieItem := Copy(Line, 1, Pos('add2basket', Line));
  62.         BeginPos := Pos('"', MovieItem) + 1;
  63.         EndPos := Pos('" class', MovieItem);
  64.         MovieAddress := Copy(MovieItem, BeginPos, EndPos - BeginPos);
  65.         BeginPos := Pos('">', MovieItem) + 2;
  66.         EndPos := Pos('</a>', MovieItem);
  67.         MovieTitle := Copy(MovieItem, BeginPos, EndPos - BeginPos);
  68.         List.Text := MovieItem;
  69.         MovieItem := Trim(List.GetString(3));
  70.         if MovieItem <> '' then
  71.           MovieTitle := MovieTitle + ' [' + MovieItem + ']';
  72.         MovieItem := Trim(List.GetString(9));
  73.         if MovieItem <> '' then
  74.           MovieTitle := MovieTitle + ' (' + MovieItem + ')';
  75.         PickTreeAdd(MovieTitle, MovieAddress);
  76.         Delete(Line, 1, 25);
  77.       end;
  78.     until TitlePos = 0;
  79.     List.Free;
  80.   end;
  81.   if PickTreeExec(Address) then
  82.     AnalyzeMoviePage(Address);
  83. end;
  84.  
  85. procedure AnalyzeMoviePage(Address: string);
  86. var
  87.   Line, Value, FullValue: string;
  88.   LineNr: Integer;
  89.   BeginPos, EndPos: Integer;
  90.   Page: TStringList;
  91. begin
  92.   Line := GetPage(Address);
  93.   BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  94.   EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  95.   Line := Copy(Line, BeginPos, EndPos - BeginPos);
  96.  
  97.   // title
  98.   BeginPos := Pos('<span class="detail-title">', Line);
  99.   Delete(Line, 1, BeginPos);
  100.   BeginPos := Pos('>', Line) + 1;
  101.   EndPos := Pos('</', Line);
  102.   Value := Copy(Line, BeginPos, EndPos - BeginPos);
  103.   HTMLDecode(Value);
  104.   SetField(fieldTranslatedTitle, Value);
  105.  
  106.   // nbr de disques
  107.   BeginPos := Pos('<b>Nombre de disque(s)</b>: ', Line);
  108.   Delete(Line, 1, BeginPos);
  109.   BeginPos := Pos(';', Line) + 1;
  110.   EndPos := Pos('<br', Line);
  111.   Value := Copy(Line, BeginPos, EndPos - BeginPos);
  112.   HTMLDecode(Value);
  113.   SetField(fieldDisks, Value);
  114.  
  115.   // picture
  116.   BeginPos := Pos('http://www.dvdzone2.com/pictures/big/', Line);
  117.   if BeginPos > 0 then
  118.   begin
  119.     Delete(Line, 1, BeginPos - 1);
  120.     EndPos := Pos('"', Line);
  121.     Value := Copy(Line, 1, EndPos - 1);
  122.     GetPicture(Value);
  123.   end;
  124.  
  125.   // description
  126.   BeginPos := Pos('<p>', Line);
  127.   Delete(Line, 1, BeginPos + 2);
  128.   EndPos := Pos(#13, Line);
  129.   Value := StringReplace(Copy(Line, 1, EndPos - 1), '<p>', #13#10#13#10);
  130.   HTMLRemoveTags(Value);
  131.   HTMLDecode(Value);
  132.   SetField(FieldDescription, Value);
  133.  
  134.   // rating
  135.   BeginPos := Pos('note globale', Line);
  136.   if BeginPos > 0 then
  137.   begin
  138.     Delete(Line, 1, BeginPos);
  139.     BeginPos := Pos('<b>', Line);
  140.     if BeginPos > 0 then
  141.     begin
  142.       BeginPos := BeginPos + 3;
  143.       EndPos := Pos(',', Line);
  144.       Value := Copy(Line, BeginPos, EndPos - BeginPos);
  145.       SetField(fieldRating, Value);
  146.     end;
  147.   end;
  148.  
  149.   Page := TStringList.Create;
  150.   BeginPos := Pos('<td height="120" width="50%" class="dvd-detail-border-c" valign="top" align="left">', Line);
  151.   Delete(Line, 1, BeginPos);
  152.   EndPos := Pos('</table>', Line);
  153.   Page.Text := Copy(Line, 1, EndPos);
  154.  
  155.   // titre original
  156.   SetField(fieldOriginalTitle, GetInfo('<b>Titre original', Page));
  157.  
  158.   // director
  159.   SetField(fieldDirector, GetInfo('<b>RΘalisateur(s)', Page));
  160.  
  161.   // actors
  162.   SetField(fieldActors, StringReplace(GetInfo('<b>Acteurs', Page), ' - ', ', '));
  163.  
  164.   // country
  165.   SetField(fieldCountry, GetInfo('<b>Pays', Page));
  166.  
  167.   // year
  168.   SetField(fieldYear, GetInfo('<b>AnnΘe', Page));
  169.  
  170.   // studio (producer)
  171.   SetField(fieldProducer, GetInfo('<b>Studio', Page));
  172.  
  173.   // category
  174.   SetField(fieldCategory, GetInfo('<b>Genres', Page));
  175.  
  176.   // format vidΘo
  177.   SetField(fieldVideoFormat, GetInfo('<b>Format vidΘo', Page));
  178.  
  179.   // length
  180.   Value := GetInfo('<b>DurΘe', Page);
  181.   EndPos := Pos('min', Value);
  182.   SetField(fieldLength, Copy(Value, 1, EndPos - 2));
  183.  
  184.   // Sous-titres
  185.   BeginPos := Pos('<span class="px11">SOUS-TITRES</span>', Line);
  186.     Delete(Line, 1, BeginPos);
  187.   BeginPos := Pos('</td>', Line);
  188.     Delete(Line, 1, BeginPos);
  189.   BeginPos := Pos('<td class=""dvd-detail-border-left"" align=""center"" valign=""middle"" colspan=""2"">', Line);
  190.     Delete(Line, 1, BeginPos + 96);
  191.   Value := Copy(Line , BeginPos  , Length(Line));
  192.   EndPos := Pos('</td>', Value);
  193.   Value := Copy(Value , 1, EndPos -5);
  194.     HTMLRemoveTags(Value);
  195.     HTMLDecode(Value);
  196.   SetField(fieldSubtitles, Value);
  197.  
  198.   // special features (comments)
  199.   BeginPos := Pos('<span class="detail-title">Les Bonus</span>', Line);
  200.   Delete(Line, 1, BeginPos);
  201.   EndPos := Pos('</table>', Line);
  202.   Delete(Line, EndPos, Length(Line));
  203.   FullValue := '';
  204.   repeat
  205.     BeginPos := Pos('</tr>', Line);
  206.     Delete(Line, 1, BeginPos);
  207.     BeginPos := Pos('<tr>', Line);
  208.     if BeginPos > 0 then
  209.     begin
  210.       BeginPos := Pos('<b>', Line);
  211.       if BeginPos > 0 then
  212.       begin
  213.         Value := Copy(Line, BeginPos + 3, Length(Line));
  214.         EndPos := Pos(#10, Value);
  215.         Value := StringReplace(Copy(Value, 1, EndPos - 1), '<br>', ' ');
  216.         HTMLRemoveTags(Value);
  217.         HTMLDecode(Value);
  218.         FullValue := FullValue + '- ' + Value + #13#10;
  219.       end;
  220.     end;
  221.   until (Pos('<tr>', Line) = 0) or (Pos('<b>', Line) = 0);
  222.   if FullValue <> '' then
  223.     SetField(fieldComments, 'Bonus:' + #13#10 + FullValue);
  224.  
  225.   Page.Free;
  226.   //DisplayResults;
  227. end;
  228.  
  229. function GetInfo(Name: string; Page: TStringList): string;
  230. var
  231.   LineNr, BeginPos, EndPos: Integer;
  232.   Value, Line: string;
  233. begin
  234.   LineNr := FindLine(Name, Page, 0);
  235.   if LineNr > 0 then
  236.   begin
  237.     Line := Page.GetString(LineNr);
  238.     BeginPos := Pos(': ', Line) + 7;
  239.     EndPos := Pos('<br>', Line);
  240.     Value := Copy(Line, BeginPos, EndPos - BeginPos);
  241.     HTMLRemoveTags(Value);
  242.     HTMLDecode(Value);
  243.     Result := Value;
  244.   end else
  245.     Result := '';
  246. end;
  247.  
  248. begin
  249.   if CheckVersion(3,5,0) then
  250.   begin
  251.     MovieName := GetField(fieldOriginalTitle);
  252.     if MovieName = '' then
  253.       MovieName := GetField(fieldTranslatedTitle);
  254.     if Input('DVDZone2 (FR) Import', 'Entrez le titre du film:', MovieName) then
  255.     begin
  256.       GetPage('http://www.dvdzone2.com/language.asp?id=fra&dest=dvd');
  257.       AnalyzePage('http://www.dvdzone2.com/dvd/search.asp?t=1&kw=' + UrlEncode(MovieName) + '&kwt=t&pl=all');
  258.     end;
  259.   end else
  260.   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  261. end.
  262.